<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'资源添加', styles:'bootstrap,font-awesome,animate,style,dtvalidate,layer,chosen,layui'}){%>
    <style type="text/css">
        body{padding-top:10px;}
    </style>
    <%}%>
</head>
<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="col-sm-offset-1 col-sm-10" style="margin-left: -10px;width: 100%;">
                <button type="button" class="return-btn btn btn-w-m btn-primary">返回</button>
                <div style="border-color: #e7eaec;border-image: none;border-style: solid solid none;border-width: 4px 0px;padding-bottom: 15px;margin-top: 10px;" ></div>
            </div>
        </div>
    </div>
</div>
<!-- START 内容部分 -->
<div class="container" >
    <form class="form-horizontal" id="info-form" method="post" autocomplete="off" style="margin: auto">
        <input type="hidden" name="materialId" id="materialId" value="${id}">
        <div class="form-group">
            <label class="col-sm-2 control-label">渠道:</label>
            <div class="col-sm-3">
                <input type="text" name="channel" id="channel" value="${channel}" class="form-control"  readonly/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">Listing:</label>
            <div class="col-sm-3">
                <input type="text" name="listing" id="listing" value="${listing}" class="form-control"  readonly/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">辅料类型:</label>
            <div class="col-sm-6">
                <select   xm-select="materialFLLX" xm-select-radio xm-select-search>
                    <option value="">请选择</option>
                    <%for(var dict in FLLX){%>
                    <option value="${dict.detailName}">${dict.detailName}</option>
                    <%}%>
                </select>
                <input type="hidden" id="materialFL" name="materialFL" >
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label text-right">附件：</label>
            <div class="col-sm-6">
                <button  class="layui-btn layui-btn-sm import-show-btn" style="margin-left: -2px" type="button" id="import-show-btn"  name="import-show-btn">
                    <i class="layui-icon"></i>导入附件
                </button>
                <input type="hidden" id="materialShowFile" value="" name="materialShowFile">
            </div>
        </div>


        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="save-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </div>
    </form>
</div>
<!-- END 内容部分 -->

<!-- START 公共脚本 -->
<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,dtvalidate,dtvalidate-lang-zh_cn,laydate,chosen,chosen-demo,layer,layui,upload'}){}%>
<!-- END 公共脚本 -->
<script>
    laydate.render({
        elem: '#createPlanPlaceDate',
        type: 'date',
        format: 'yyyy-MM-dd'
    });

    layui.use('upload', function(){
        var upload = layui.upload;
        upload.render({
            elem: '#import-show-btn', //绑定元素,
            accept:'file',
            url: '/sea/physical/refusedTax/import/', //上传接口
            data:{},
            before:function () {
                layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
            }
            ,done: function(data){
                if( data.ok ){
                    layer.msg("生成成功！",{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                            $("#materialShowFile").val(data.data);
                            layer.closeAll();
                        }});
                }else{
                    layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                            layer.closeAll();
                        }});

                }
            }
            ,error: function(){
                //请求异常回调
                layer.closeAll();
            }
        });
    });

    layui.use('upload', function(){
        var upload = layui.upload;
        upload.render({
            elem: '#import-design-btn', //绑定元素,
            accept:'file',
            url: '/sea/physical/refusedTax/import/', //上传接口
            data:{},
            before:function () {
                layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
            }
            ,done: function(data){
                if( data.ok ){
                    layer.msg("生成成功！",{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                            $("#materialDesignFile").val(data.data);
                            layer.closeAll();
                        }});
                }else{
                    layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                            layer.closeAll();
                        }});

                }
            }
            ,error: function(){
                //请求异常回调
                layer.closeAll();
            }
        });
    });

    var cvalidator;
    $(function(){

        formSelects.render('refusedPlanNo');
        //初始化验证器
        cvalidator = $.fn.dlshouwen.validator.init($('#info-form'));
        //提交表单
        $('.save-btn').on('click',function(){

            var fl=(formSelects.value('materialFLLX', 'nameStr'));
            if(fl==''){
                layer.msg("辅料类型不能为空！",{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                        layer.closeAll();
                    }});
            }else {
                $("#materialFL").val(fl);
                $.post('/sea/operate/related/materialDetail/save.do',$('#info-form').serialize(),function(data){
                    if( data.ok ){
                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
                            }});
                    }else{

                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                            }});

                    }
                });
            }
        });

        //返回
        $('.return-btn').on('click',function(){
            parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
        });
    });


</script>
</body>
</html>